	<meta content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no" name="viewport">
	<link rel="stylesheet" type="text/css" href="__PUBLIC__/css/mobile/main.css" media="all" />
	<link rel="stylesheet" type="text/css" href="__PUBLIC__/css/mobile/style.css" media="all" />
	<link href="__PUBLIC__/css/bootstrap.min.css" rel="stylesheet" type="text/css"/>
	<!-- iconfont图形样式 -->
	<link rel="stylesheet" href="__PUBLIC__/css/mobile/iconfont/iconfont.css" type="text/css">
	    <link rel="stylesheet" type="text/css" href="__PUBLIC__/user/com/css/normalize.css" />
    <link rel="stylesheet" type="text/css" href="__PUBLIC__/user/com/css/default.css">
    <link rel="stylesheet" type="text/css" href="__PUBLIC__/user/com/css/hcom.css">
	<style type="text/css">
			li{margin-left: 20px;line-height: 25px;font-size: 18px;}
	.three_status{height: 20px;width:20px;margin-top: 5px;}
	li{position: relative;}
	li .three_status{width:19%;float: left;}
	li .lab{width:79%;float: right;}
	.checktop{padding-top: 14px;padding-bottom: 14px;}
      .title{width:100px;}
      input{border: 0;font-size: 14px;}
      .plus{text-align:center;margin-top: 42px;margin-bottom: 14px;}
      .plus-one{text-align:center;color:#898989;margin-bottom: 42px;}
      .plus1{margin-top:4px;margin-left: 14px;margin-left: 20px;}
      .plus,.plus1{font-size:30px;}
      .five-p{color:#898989;margin-top: 13px;margin-left: 27px;}
      .main{height: 90%;}
      /*照片弹窗*/
      .tc{height: 100%;width: 100%;z-index: 60;
        position: absolute;background-color: #000;top: 0;}
      .photo-clip-view{background-color: #494a5f;}
      .hfoot{height: 45px;line-height: 45px;}
      #clipBtn,.checkfile,.back{color: #fff;text-align: center;}
      /**end**/
      .plus img{height: 160px;width:130px; }
      .threep img{height: 80px;width: 80px;margin-left: 14px;}
      .threep :nth-child(4){display: none;}
      .tobehide{display: none;}
	</style>
<!--header页头文件-->

 
<div class="main wd_zl">
	<ul class="zt">
    <input type="hidden" id="id_two" name="id2" value="{$id}">
		<input type="hidden" id="photourl" name="id2" value="">
		<foreach name="t_status" item="ts">
			<li><input id="element{$key}" class="three_status" type="checkbox" onclick="go_photo(this)" isnext="{$ts.is_next}" name="{$ts.id}" value="1"><label class="lab">{$ts.name}</label></li>
		</foreach>
		<li>
      <div class="checktop hcheck box threep addphoto tobehide">
          <div class="plus1" onclick="tp(this)">+</div>
          <div class="hbox five-p">添加图片</div>
      </div>
    </li>
    <li>
        <div class="hbox five-p addphoto tobehide"><a class="btn btn-primary" id="upPhoto" onclick="upPhoto()">确认上传图片</a></div>
    </li>
	</ul>	
	
</div>
<div class="device-foot clear">
	<a onclick="status_ok()" id="submit" class="btn btn-primary">提交</a>
</div>

<script src="__PUBLIC__/js/jquery-1.10.1.min.js" type="text/javascript"></script>
<script src="__PUBLIC__/js/jquery-migrate-1.2.1.min.js" type="text/javascript"></script>
<script src="__PUBLIC__/plugins/layer/layer.min.js"></script>
<script src="__PUBLIC__/user/com/js/iscroll-zoom.js"></script>
<script src="__PUBLIC__/user/com/js/hammer.js"></script>
<script src="__PUBLIC__/user/com/js/jquery.photoClip.js"></script>
<script src="__PUBLIC__/user/com/js/msgalert.js"></script>
<script type="text/javascript">
   var img="";
    var imgs=new Array();
    var html='<div id="niss" class="tc"><div id="clipArea" class="main"></div>'+
    '<div class="hfoot">'+
    '<input type="file" id="file" style="display:none;">'+
    '<button id="clipBtn" style="display:none;"></button>'+
    '<div class="row">'+
    '<div class="col back" onclick="back()">返回</div>'+
    '<div class="col checkfile">'+
    '<label for="file" >选择图片</label>'+
    '</div>'+
    '<div class="col checkfile">'+
    '<label class="" for="clipBtn" >确定</label>'+
    '</div>'+
    '</div>'+
    '</div></div>';
	function go_photo(obj){

		var is_choose = $(obj).attr("checked");
		//判断两个选项是否被同时选中
		if (is_choose == "checked") {
  			var this_id = $(obj).attr('id');
  			if (this_id == "element0") {
    				var element1 = $("#element1").attr("checked");
    				if (element1 == "checked") {
    					  $(obj).removeAttr('checked');
                layer.msg("不能多选");
                return false;
    				}
            $(".addphoto").removeClass("tobehide");
            
  			}
  			if (this_id == "element1") {
    				var element0 = $("#element0").attr("checked");
    				if (element0 == "checked") {
    					   $(obj).removeAttr('checked');
                layer.msg("不能多选");
                return false;
    				}
            $(".addphoto").removeClass("tobehide");
  			}
		}
		//若两个选项没有被同时选中，则跳出拍照选项
	}
	function tp(obj) {
      $('#first').hide();
      $("body").append(html);
      $("#clipArea").photoClip({
            width: 300,
            height: 230,
            file: "#file",
            ok: "#clipBtn",
            // loadStart: function() {
            //   console.log("照片读取中");
            // },
            // loadComplete: function() {
            //   console.log("照片读取完成");
            // },
          clipFinish: function(dataURL) {
                    imgs.push(dataURL);
                    $(obj).next().hide();
                    $(obj).before("<img src='"+dataURL+"'></img>");
                    $(obj).css({'margin-top':'24px','margin-left':'30px'});
                    $('.tc').remove();
                    $('#first').show();
              }
          });
    }
    function back(){
	    $('#niss').remove();
	 }
	function status_ok(){
		var index = parent.layer.getFrameIndex(window.name);
		var id_two = $("#id_two").val();
		var exdate=new Date();
		exdate.setDate(exdate.getDate()+1);
		statusThree = {}; var isemp = 0;
		$('input.three_status').each(function(){
			if (this.checked) {
				isemp = isemp +1;
        if ($(this).attr('isnext') == 1 && $("#photourl").val() == "") {
          alert("请先拍照"); 
          return false;
        }
        statusThree[this.name] = $("#photourl").val();
        if($(this).attr('isnext') != 1){
          statusThree[this.name] = 1;
        }
			}
		});
		if (isemp != 0) {
			var statusThree = escape(JSON.stringify(statusThree));
			//获得上一级的id
			/*var id_two = $("#id_two").val();*/
			//将这级的内容储存在cookie中。
			/*var c_name = "statusTwo" + id_two;*/
			/*var st3 = escape(JSON.stringify(statusThree));*/
			parent.$("#stTwo{$id}").val(statusThree);
		}
		parent.layer.close(index);
	}

    function upPhoto(){
        var url = "{:U('Photo/add')}";
        var postData = {};
        postData['img'] = imgs;
        // alert(JSON.stringify(postData))
        $.post(url,postData,function(result){
            // alert(JSON.stringify(result))
            if(result.status==1){
              $("#photourl").val(result.message);
                alert("上传成功");
            }
            if(result.status==0){
                //失败
                alert("上传失败");
            }
        },"JSON");
        return false;
    };
</script>